fix: use container queries for MediaBlock responsive sizing#1113
Open
claude[bot] wants to merge 3 commits into
Open
fix: use container queries for MediaBlock responsive sizing#1113claude[bot] wants to merge 3 commits into
claude[bot] wants to merge 3 commits into
Conversation
Switch MediaBlock from viewport-based breakpoints (md:, lg:) to CSS container query breakpoints (@sm:, @lg:) so responsive image sizing adapts to the parent container width instead of the viewport. This fixes incorrect sizing when MediaBlock is embedded in narrower containers like the blog post layout (max-w-[48rem]). Also update InlineMediaBlock sizes attribute to use conservative container-relative pixel estimates instead of viewport-relative vw units. Changes: - MediaBlock: Add @container to wrapper div, use @sm:/@lg: container query classes instead of md:/lg: viewport breakpoints - MediaBlock: Remove unused cssVariables import - InlineMediaBlock: Replace vw-based sizes hints with container-aware pixel estimates Closes #757 Co-authored-by: Rachel Fryan <rchlfryn@users.noreply.github.com>
Contributor
|
Preview deployment: https://claudexissue-757-20260611-2132.preview.avy-fx.org |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Switch MediaBlock from viewport-based breakpoints (
md:,lg:) to CSS container query breakpoints (@sm:,@lg:) so responsive image sizing adapts to the parent container width instead of the viewport. This fixes incorrect sizing when MediaBlock is embedded in narrower containers like the blog post layout (max-w-[48rem]).Also updates InlineMediaBlock
sizesattribute to use conservative container-relative pixel estimates instead of viewport-relativevwunits.Related Issues
Closes #757
Key Changes
src/blocks/Media/Component.tsx:@containerclass to the wrapper div so child elements can use container query breakpointsmax-w-*classes from viewport breakpoints (md:max-w-sm,lg:max-w-md) to container query breakpoints (@sm:max-w-sm,@lg:max-w-md)sizesattribute to use640px(thesmbreakpoint) as the threshold instead of768px(md), providing more conservative estimatescssVariablesimportsrc/blocks/InlineMedia/Component.tsx:${resolvedSize}vwsizes hints (e.g."25vw","50vw") with container-aware pixel estimates (e.g."(max-width: 640px) 25vw, 192px")sizesForWidthlookup map with descriptive commentsHow to test
nwac.localhost:3000/blog/...)max-w-[48rem]constraintsmall,medium, andlargesizes visually adapt to the container width rather than the viewport width🤖 Generated with Claude Code